package com.exer.dataload.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Utils {
    /**
     * @param str        目标字符串
     * @param regex      正则表达式
     * @param groupIndex 捕获组
     * @return 正则表达式匹配的结果
     */
    public static String findSub(String str, String regex, int groupIndex) {
        Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
        Matcher matcher = pattern.matcher(str);
        if (matcher.find()) {
            return matcher.group(groupIndex);
        }
        return null;
    }
}
